package com.base.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.base.annotation.MultiRequestBody;
import com.base.service.EmpiPatientService;
import com.base.service.PatientinfoBaseService;
import com.base.utils.Result;
import com.base.utils.ResultUtil;
import com.base.vo.EmpiPatientRel;
import com.base.vo.PageVo;
import com.base.vo.PatientinfoBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wnhuang
 * @Package com.base.controller
 * @date 2021-02-08 23:12
 */
@RestController
@RequestMapping("/patient")
public class EmpiPatientController {

    @Autowired
    EmpiPatientService empiPatientService;

    @Autowired
    PatientinfoBaseService patientinfoBaseService;

    @PostMapping("/getList")
    public Result getPatientList(@MultiRequestBody PatientinfoBase patientinfoBase,@MultiRequestBody PageVo pageVo) {
        Page page = patientinfoBaseService.getList(patientinfoBase, pageVo);
        return ResultUtil.success(page);
    }

    @GetMapping("/getRelList/{id}")
    public Result getPatientRelList(@PathVariable("id") String id){
        return ResultUtil.success(empiPatientService.getPatientRelList(id));
    }

    @PostMapping("/getMergeList")
    public Result getMergeList(@MultiRequestBody PatientinfoBase patientinfoBase,@MultiRequestBody PageVo pageVo) {
        Page page = patientinfoBaseService.getMergeList(patientinfoBase, pageVo);
        return ResultUtil.success(page);
    }

    @PostMapping("/getRelList")
    public Result getPatientRelListByPatientRel(@RequestBody EmpiPatientRel empiPatientRel){
        return ResultUtil.success(empiPatientService.getPatientRelList(empiPatientRel));
    }

    @GetMapping("/getCompareList/{id}")
    public Result getCompareList(@PathVariable("id") String id) throws Exception {
        return ResultUtil.success(empiPatientService.ComparePatientRel(id));
    }

    @GetMapping("/mergeRow/{id}")
    public Result mergeRow(@PathVariable("id") String id){
        empiPatientService.mergeRow(id);
        return ResultUtil.success();
    }

    @GetMapping("/spiltRow/{id}")
    public Result spiltRow(@PathVariable("id") String id){
        empiPatientService.spiltRow(id);
        return ResultUtil.success();
    }

}
